package com.macllvm.whale.ui;

import android.os.Bundle;
import android.os.Handler;
import android.app.Activity;
import android.content.Intent;
import android.widget.TextView;
import android.widget.Button;
import android.view.View;
import android.view.View.OnClickListener;
import android.net.Uri;
import com.macllvm.whale.R;

import java.lang.Override;

public  class  AboutActivity extends Activity {

    private Button mBtnEmail;
    private Button mBtnGithub;
    private Button mBtnBack;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about);

        mBtnEmail = (Button)findViewById(R.id.text_email);
        mBtnGithub = (Button)findViewById(R.id.text_github);
        mBtnBack = (Button)findViewById(R.id.btn_back);

        mBtnEmail.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
            String emailAddr = getString(R.string.about_email_to);
            String emailChooseTip = getString(R.string.about_email_choose_tip);
            Intent email = new Intent(Intent.ACTION_SEND);
            email.setType("plain/text");
            email.putExtra(Intent.EXTRA_EMAIL, new String[] {emailAddr});
            email.putExtra(Intent.EXTRA_TEXT, "body");
            startActivity(Intent.createChooser(email, emailChooseTip));
            }
        });

        mBtnGithub.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            String githubUrl = getString(R.string.about_github_url);
            Uri content_url = Uri.parse(githubUrl);
            intent.setData(content_url);
            startActivity(intent);
            }
        });

        mBtnBack.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

    }

    @Override
    public void onBackPressed() {
        finish();
    }

}